package montecarlo.GUI;

import java.awt.GridLayout;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Antoine
 */
public class MCGUI extends JFrame{
    
    protected JPanel container = new JPanel();
    protected JPanel form = new JPanel();
    protected JPanel panResult = new JPanel();
    protected JButton launch = new JButton("Launch");
    public JComboBox<String> flag = new JComboBox<String>();
    public JComboBox S = new JComboBox();
    public JComboBox X = new JComboBox();
    public JComboBox T = new JComboBox();
    public JComboBox r = new JComboBox();
    public JComboBox b = new JComboBox();
    public JComboBox v = new JComboBox();
    public JComboBox nSteps = new JComboBox();
    public JComboBox nSimulation = new JComboBox();
    public JLabel lblResult = new JLabel();
    public JLabel tempsCalcul = new JLabel();
    
    public MCGUI(){
        super();
       
        setTitle("Monte Carlo"); //On donne un titre à l'application
        setSize(400,500); //On donne une taille à notre fenêtre
        setLocationRelativeTo(null); //On centre la fenêtre sur l'écran
	    setResizable(false); //On interdit la redimensionnement de la fenêtre
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //On dit à l'application de se fermer lors du clic sur la croix
        
        container.setLayout(null); 
        form.setLayout(new GridLayout(0,2));
        
    }
    
    public void setLblResult(Double lblResult){
        this.lblResult.setText("Result : " + lblResult);
    }
    
   

	public void setTempsCalcul(Double tempsCalcul2) {
		this.tempsCalcul.setText("temps calcul : " + tempsCalcul2);
	}

	public void launch(ActionListener l){
        launch.addActionListener(l);
    }
    
    public void setComboBoxes(ArrayList<ArrayList> arguments){
        
        for(int i=1;i<arguments.size();i++){
            S.addItem(arguments.get(i).get(0));
            X.addItem(arguments.get(i).get(1));
            T.addItem(arguments.get(i).get(2));
            r.addItem(arguments.get(i).get(3));
            b.addItem(arguments.get(i).get(4));
            v.addItem(arguments.get(i).get(5));
            nSteps.addItem(arguments.get(i).get(6));
            nSimulation.addItem(arguments.get(i).get(7));
            
        }
        
        form.add(new JLabel("Flag :"));
        flag.addItem("c");
        flag.addItem("p");
        form.add(flag);
        form.add(new JLabel("S :"));
        form.add(S);
        form.add(new JLabel("X :"));
        form.add(X);
        form.add(new JLabel("T :"));
        form.add(T);
        form.add(new JLabel("r :"));
        form.add(r);
        form.add(new JLabel("b :"));
        form.add(b);
        form.add(new JLabel("v :"));
        form.add(v);
        form.add(new JLabel("Number of steps :"));
        form.add(nSteps);
        form.add(new JLabel("Number of simulations :"));
        form.add(nSimulation);
        form.add(launch);
        panResult.add(lblResult);
        panResult.add(tempsCalcul);
        form.setBounds(55,10, 300, 300);
        panResult.setBounds(55,340,300,40);
        container.add(form);
        container.add(panResult);
        this.setContentPane(container);
        this.setVisible(true);
    }
    
    
}